package com.mazaiting.web.wrapper;

import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * 包装流
 */
public class WrappedServletInputStream extends ServletInputStream {
    /**
     * 输入流
     */
    private InputStream stream;

    public WrappedServletInputStream(InputStream stream) {
        this.stream = stream;
    }

    public void setStream(InputStream stream) {
        this.stream = stream;
    }

    @Override
    public boolean isFinished() {
        return true;
    }

    @Override
    public boolean isReady() {
        return true;
    }

    @Override
    public void setReadListener(ReadListener readListener) {
    }

    @Override
    public int read() throws IOException {
        return stream.read();
    }
}